<?php require('common/isLogin.php');?>
<?php require('common/mysql.php');?>
<?php  

$sqlObj = new Sql(); 
// 检查是否是POST请求  
if ($_SERVER['REQUEST_METHOD'] === 'POST') {  
    // 从POST数据中获取其他字段  
    $catename = $_POST['catename'] ?? '';  
    // 创建SQL插入语句  
    $sql = "INSERT INTO category (name, status) VALUES ('{$catename}', 0)";  
	
    // 实例化Sql类并执行插入操作   
    $result = $sqlObj->query($sql);  
  
    if ($result) {  
        echo "<script>alert(\"申请提交成功！\");window.location.href = ''</script>";  
    } else {  
        echo "<script>alert(\"申请提交失败！\");window.location.href = ''</script>";  
    }  
  
    $sqlObj->close(); // 关闭数据库连接  
}  
  
?>  
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>Hadi.申请分类</title>
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/bootstrap.min.css" />
	</head>
	<body>
		<!--头部-->
		<div class="container-fluid header">
		  <div class="row hd_title">
			  申 请 分 类
		  </div>
		</div>
		<!--白色计算信息-->
		<!--账单明细-->
		<div class="container allzdh">
			<!--这是账单行-->
			<form action="" method="post">
			<div class="row zdh jlzd">
				<!--这是一条账单start-->
				<div class="row onezdh">
					<div class="col">
						分类名称：
					</div>
					<div class="col">
						<input type="text" value="" required placeholder="输入分类名称" name="catename" class="srje" />
					</div>
				</div>
				<div class="row onezdh">
					<!--记账按钮-->
					<div class="container text-center">
						<div class="row justify-content-center">
							<div class="col">
								<button class="jzbtn">申请</button>
							</div>
						</div>
					</div>
				</div>
				<!--这是一条账单end-->
			</div>
			</form>
			<!--这是账单行end-->
		</div>
		<div class="container text-center" style="padding-top: 20px;letter-spacing: 2px;">
			<div class="row">
				<div class="col">
					<a href="" style="color: rgb(153,153,153);font-size:14px;text-decoration: none;">申请后 , 请等待管理员审核 ~</a>
				</div>
			</div>
		</div>
		<?php include('footer.php');?>
	</body>
</html>
